package edu.ncst.baseweb.service.impl.web;

import cn.wintersun.basecommon.common.Result;
import edu.ncst.baseweb.dao.web.LabOpenTopic;
import edu.ncst.baseweb.mapper.LabOpenTopicMapper;
import edu.ncst.baseweb.service.intrer.web.LabOpenTopicService;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LabOpenTopicServiceImpl implements LabOpenTopicService {

    @Autowired
    private LabOpenTopicMapper labOpenTopicMapper;

    public Result<List<LabOpenTopic>> list(){
        List<LabOpenTopic> labOpenTopicList = labOpenTopicMapper.selectList(null);

        for (LabOpenTopic labOpenTopic : labOpenTopicList) {
            if (StringUtils.isNotEmpty(labOpenTopic.getState())) {
                if ("0".equals(labOpenTopic.getState())) {
                    labOpenTopic.setState("结题");
                } else if ("1".equals(labOpenTopic.getState())) {
                    labOpenTopic.setState("在研");
                }
            }
        }

        return Result.ok(labOpenTopicList);
    }
}
